package io.github.coderlaoliu.windows;

import io.github.coderlaoliu.panels.EncryptPanel;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.components.JBTabbedPane;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.awt.*;

public class EncryptToolsToolWindowFactory implements ToolWindowFactory {
    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        // 创建主面板
        JPanel mainPanel = new JPanel(new BorderLayout());

        // 创建选项卡面板
        JTabbedPane tabbedPane = new JBTabbedPane();

        // 创建第一个选项卡
        EncryptPanel tab1 = new EncryptPanel();

        // 创建第二个选项卡（类似地，您可以添加更多选项卡）
        JPanel tab2 = new JPanel();

        // 将选项卡面板添加到主面板
        tabbedPane.addTab("加密/解密", tab1);
        tabbedPane.addTab("更多功能开发中...", tab2);
        mainPanel.add(tabbedPane, BorderLayout.CENTER);

        // 将主面板包装为 Content
        ContentFactory contentFactory = ContentFactory.getInstance();
        Content content = contentFactory.createContent(mainPanel, "", false);

        // 将 Content 添加到工具窗口
        toolWindow.getContentManager().addContent(content);
    }
}
